package com.matt.foundation.vo;

import com.matt.domain.Children;
import com.matt.domain.course.ChildrenCourseItem;
import com.matt.foundation.DO.ChildrenCourseItemDO;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.util.Objects;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/7/11
 * *******************************
 */
@Data
public class ChildrenListVo {

    private String id;

    private String name;

    private String gender;

    private String imgUrl;

    private Integer status;


    public static ChildrenListVo of(Object[] objects) {
        ChildrenListVo vo = new ChildrenListVo();
        vo.setId(objects[0] == null ? "" : objects[0].toString());
        vo.setName(objects[1] == null ? "" : objects[1].toString());
        vo.setGender(objects[2] == null ? "" : objects[2].toString());
        if (Objects.nonNull(objects[3]) && StringUtils.isNotBlank(objects[3].toString()))
            vo.setImgUrl(objects[3].toString());
        return vo;
    }

    public static ChildrenListVo ofItem(ChildrenCourseItemDO item) {
        ChildrenListVo vo = new ChildrenListVo();
        vo.setId(item.getId());
        vo.setName(item.getName());
        vo.setGender(item.getGender().toString());
        vo.setImgUrl(item.getImgUrl());
        return vo;
    }


    public static ChildrenListVo of(Children children) {
        ChildrenListVo vo = new ChildrenListVo();
        vo.setId(children.getId());
        vo.setName(children.getName());
        vo.setGender(children.getGender() == null ? null : children.getGender().toString());
        if (StringUtils.isNotBlank(children.getImgUrl()))
            vo.setImgUrl(children.getImgUrl());
        vo.setStatus(children.getStatus());
        return vo;
    }
}
